<?php
// Use Connect Script
include("asn-config.php");
require_once('./class.rc4crypt.php');

class Login
{
    public function doLogin($username, $password)
    {
        $data = $password;

        $e = rc4crypt::encrypt(PWD, $data);
        $e = bin2hex($e);

        $user_query = "SELECT * FROM users WHERE username = '$username'";
        $user_result = mysql_query($user_query);
        $user_row = mysql_fetch_assoc($user_result);

        if ( $user_row["username"] != null )
        {
            $pass_query = "SELECT * FROM users WHERE username = '$username' AND password='$e'";
            $pass_result = mysql_query($pass_query);
            $pass_row = mysql_fetch_assoc($pass_result);

            if ( $pass_row != null )
            {
                return PWD;
            }
            else
            {
                return "Incorrect password";
            }
        }
        else
        {
            return "No such user";
        }
    }
}

?>